<template>
  <a-modal
    :width="720"
    title="新建内推"
    :visible="visible"
    :footer="null"
    :maskClosable="false"
    :keyboard="false"
    :destroyOnClose="true"
    @cancel="$emit('update:visible', false)"
  >
    <a-steps :current="current" class="mb24" style="padding: 0 32px;">
      <a-step title="选择职位" />
      <a-step title="选择内推范围" />
      <a-step title="赏金设置" />
    </a-steps>
    <selectPosition v-if="current === 0" :selectedList="selectPositionArr" @upDate="upDate" />
    <selectScope v-if="current === 1" :selectedList="selectScopeArr" @upDate="upDate" />
    <selectSet v-if="current === 2" :selectPositionArr="selectPositionArr" :selectScopeArr="selectScopeArr" @upDate="upDate" />
  </a-modal>
</template>

<script>
import selectPosition from "./selectPosition";
import selectScope from "./selectScope";
import selectSet from "./selectSet";
export default {
  props: {
    visible: {
      type: Boolean,
      default: false
    }
  },
  components: {
    selectPosition,
    selectScope,
    selectSet
  },
  data() {
    return {
      current: 0,
      selectPositionArr: [],
      selectScopeArr: []
    };
  },
  watch: {
    visible(val) {
      if (val) {
        this.current = 0;
        this.selectPositionArr = [];
        this.selectScopeArr = [];
      }
    }
  },

  methods: {
    upDate(i, e) {
      if (i === -2) {
        this.$emit("update:visible", false);
        this.$emit("upDate", false);
      }
      if (i === -1) {
        this.$emit("update:visible", false);
      }
      if (i === 1 && e) {
        this.selectPositionArr = e;
      }
      if (i === 2 && e) {
        this.selectScopeArr = e;
      }
      this.current = i;
    }
  }
};
</script>
<style lang="scss" scoped></style>
